/*
 *  HOME CAROUSEL
 *  Showcase Clients and Ventures
 *
 */

 /* Initial variables (will change inside media queries) */
$home-carousel-width: 257px;
$home-carousel-height: 180px;
$home-carousel-margin: 10px;
$home-carousel-padding: 76px;
$home-carousel-duration: .2s;
$home-carousel-boxShadow-spread: 50px;
$home-carousel-transition-scale: 0.95;
$home-carousel-transition-scale-further: 0.9;
$large-screen-right-indent: 130px;
$home-carousel-small-screen-offset: 95px;

.scroll-wrapper-home-carousel-products,
.scroll-wrapper-home-carousel-ventures {
  height: auto;
  padding-left: 0;
  padding-right: 0;
  box-sizing: content-box;
  @include core-vertical-padding();
}

.home-carousel {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  transform: translateZ(0);
  max-width: 455px;
  margin: 0 auto;
}

.home-carousel-item-text {
  position: relative;
  z-index: 20;
  width: 75%;
  top: 30px;

  h2 {
    color: #111;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
  }

  @media screen and (min-width: $bp-medium) {
    top: 40px;
  }
  @media screen and (min-width: $bp-large) {
    top: 60px;
  }
}

.home-carousel-item-description {
  display: none;
}

.home-carousel-visual-content {
  width: 100%;
  height: 100%;

  > div,
  > img {
    @include box-shadow();
  }
}

.home-carousel-item-image {
  display: flex;
  width: 100%;
  height: auto;

  img,
  video {
    width: 100%;
    height: auto;
  }
}

.view-carousel-related-page {
  display: flex;
  align-items: center;
  transition: opacity .2s ease-in-out;
  margin-top: 70px;

  button {
    @include buttonStyle(true);
    @include buttonColor();
    margin: 0 auto;
    display: inline-block;
  }
}

.home-carousel-items {
  position: relative;
  -webkit-font-smoothing: antialiased;
  margin-left: 20px;
}

.home-carousel-shuffle {
  cursor: pointer;
  position: absolute;
  bottom: 85px;
  right: 20px;
  z-index: 100;
  transition: opacity .2s ease-in-out;
}

.home-carousel-timer-control {
  width: 20px;
  height: 20px;
  margin-right: 30px;
}

.home-carousel-item {
  display: flex;
  justify-content: center;
  flex-direction: column;
  cursor: pointer;
  display: none;

  .section-title {
    margin-bottom: 7px;
  }

  .videoBackground {
    position: relative;

    video {
      position: relative;
      top: auto;
      left: auto;
      transform: none;
    }
  }

  &.active {
    display: block;
  }
}

@media screen and (min-width: 450px) {
  .home-carousel {
    padding: 0 20px;
  }
  .home-carousel-items {
    margin-left: 0;
  }
  .home-carousel-shuffle {
    right: 20px;
  }
}





@media screen and (min-width: $bp-tablet) {
  $home-carousel-width: 380px;
  $home-carousel-height: 258px; /* 266 */
  $home-carousel-margin: 20px;
  $home-carousel-padding: 115px;

  .home-carousel {
    max-width: none;
    margin: 0;
    padding: 0;
  }

  .home-carousel-items {
    height: (2 * $home-carousel-height) + $home-carousel-margin;
    display: flex;
    flex: 1;
    justify-content: center;
    align-items: center;
    margin-left: 0;
  }

  .home-carousel-item-text {
    position: absolute;
    top: 60px;
    z-index: 1;
    width: 65%;
    visibility: hidden;
    transition: visibility $home-carousel-duration linear;
    opacity: 1;

    h2 {
      overflow: visible;
      white-space: pre-wrap;
    }
  }

  .home-carousel-item-description {
    display: block;
    font-size: 16px;
    padding-top: 20px;
    opacity: 0;
    transform: translateY(15px);
    transition: all .2s ease-in;
  }

  .home-carousel-item-image {
    visibility: hidden;
    transition: all $home-carousel-duration linear;
  }

  .home-carousel-item.active {
    display: block;

    .home-carousel-item-text,
    .home-carousel-item-image {
      visibility: visible;
    }
  }

  .home-carousel-item {
    position: absolute;
    top: 50%;
    left: 0;
    display: block;

    .home-carousel-item-image {
      transform: scale($home-carousel-transition-scale);
    }

    &.even {
      right: 5%;
      left: auto;
      transform: translate(0, -($home-carousel-height + $home-carousel-margin));
      z-index: 2;

      .home-carousel-item-text {
        left: 0;
        margin-left: -$home-carousel-padding;
      }
      .home-carousel-item-image {
        align-items: flex-end;
      }
    }

    &.odd {
      z-index: 1;
      transform: translate(0, $home-carousel-margin);
      right: 50%;
      left: 5%;
      right: auto;

      .home-carousel-item-text {
        left: 100%;
        right: 0;
        margin-left: -95px;
      }

      .home-carousel-item-image {
        align-items: flex-start;
        align-self: flex-end;
      }
    }

    &:not(.active) {
      z-index: 0;
    }

    &.previous {
      z-index: 5;
    }

    &.previous + &.previous {
      z-index: 4;
    }

    &.active {
      z-index: 8;

      &:hover {
        z-index: 9;
      }

      & + &.active {
        z-index: 6;

        &:hover {
          z-index: 8;
        }
      }

      .home-carousel-item-image {
        transform: scale(1);
      }

      .home-carousel-item-text,
      .home-carousel-item-image {
        transition-delay: $home-carousel-duration;
      }
    }

    &.previous {
      &.odd {
        .home-carousel-item-text,
        .home-carousel-item-image {
          transition-delay: $home-carousel-duration;
        }
      }
    }
    &.active.odd {
      .home-carousel-item-text,
      .home-carousel-item-image {
        transition-delay: $home-carousel-duration * 2;
      }
    }

    .home-carousel-item-image:after {
      content: "";
      width: 250px;
      position: absolute;
      top: 0;
      right: 0;
      bottom: 0;
      background: linear-gradient(-90deg, white, transparent);
      opacity: 0;
      transition: opacity .15s ease-in-out;
      z-index: 10;
    }

    &.even .home-carousel-item-image:after {
      right: auto;
      left: 0;
      background: linear-gradient(-90deg, transparent, white);
    }

    &:hover {
      .home-carousel-item-image:after {
        opacity: .75;
        transition-duration: .32s;
      }

      .home-carousel-item-description {
        opacity: 1;
        transform: translateY(0);
      }
    }
  }

  .home-carousel-item-image {
    position: relative;
    width: $home-carousel-width;
    height: $home-carousel-height;

    img,
    video {
      width: 100%;
      height: auto;
    }

    .videoBackground {
      position: relative;
    }
  }

  .home-carousel-visual-content {
    max-width: none;
  }

  .home-carousel-visual-content-image {
    background-size: cover;
    background-position: 50%;
    background-repeat: no-repeat;
    width: 100%;
    height: 100%;
  }

  .home-carousel-shuffle {
    right: 70px;
    bottom: -5px;
  }
}

@media screen and (min-width: $bp-medium) {
  $home-carousel-width: 485px;
  $home-carousel-height: 329px; /* 340 */
  $home-carousel-margin: 20px;
  $home-carousel-padding: 115px;

  .home-carousel-items {
    height: (2 * $home-carousel-height) + $home-carousel-margin;
  }

  .home-carousel-item {
    &.even {
      transform: translate(0, -($home-carousel-height + $home-carousel-margin));

      .home-carousel-item-text {
        margin-left: -$home-carousel-padding;
      }
    }

    &.odd {
      transform: translate(0, $home-carousel-margin);
    }
  }

  .home-carousel-item-image {
    width: $home-carousel-width;
    height: $home-carousel-height;
  }
}






/* DIFFERENT LAYOUT */

@media screen and (min-width: $bp-large) {
  $home-carousel-width: 519px;
  $home-carousel-height: 352px;
  $home-carousel-margin: -50px;
  $home-carousel-controls-padding: 30px;
  $home-carousel-grid: 57px;
  $home-carousel-gutter: 20px;
  $home-carousel-padding: $home-carousel-grid + $home-carousel-gutter;

  .home-carousel-items {
    height: (2 * $home-carousel-height) + $home-carousel-margin;
  }

  home-carousel-item-image {
    transforom: transform .32s ease-in-out;
    transition-delay: 0s;
  }

  .home-carousel-item-text {
    top: 80px;
    width: 55%;
  }

  .home-carousel-item-description {
    font-size: 18px;
  }

  .home-carousel-item {

    &.even .home-carousel-item-image:after {
      left: 0;
      right: auto;
    }

    &.odd .home-carousel-item-image:after {
      left: auto;
      right: 0;
    }

    &.even {
      left: 60px;
      right: auto;
      padding-left: $home-carousel-padding;
      transform: translate(0, -($home-carousel-height + $home-carousel-margin));

      .home-carousel-item-text {
        margin-left: 0;
        left: 0;
      }
      .home-carousel-item-image {
        transform: scale($home-carousel-transition-scale);
      }
    }

    &.odd {
      right: $large-screen-right-indent;
      left: auto;
      padding-right: $home-carousel-padding;
      display: flex;
      align-items: flex-end;
      transform: translate(0, $home-carousel-margin);

      .home-carousel-item-text {
        left: $home-carousel-width - $home-carousel-grid;
        margin-left: -10px;
      }
      .home-carousel-item-image {
        transform: scale($home-carousel-transition-scale-further);
      }
    }

    &.previous {
      &.odd {
        .home-carousel-item-text,
        .home-carousel-item-image {
          transition-delay: 0s;
        }
      }
      &.even {
        .home-carousel-item-text,
        .home-carousel-item-image {
          transition-delay: $home-carousel-duration;
        }
      }
    }
    &.active {
      &.odd {
        .home-carousel-item-text,
        .home-carousel-item-image {
          transition-delay: $home-carousel-duration;
        }
      }
      &.even {
        .home-carousel-item-text,
        .home-carousel-item-image {
          transition-delay: $home-carousel-duration * 2;
        }
      }
    }

    &.active {

      &.even {
        .home-carousel-item-image {
          transform: scale(1);
        }
      }
      &.odd {
        .home-carousel-item-image {
          transform: scale($home-carousel-transition-scale);
        }

        &:hover {
          .home-carousel-item-image {
            transform: scale(1);
            transition-delay: 0s;
          }
        }
      }

      &.even.otherIsHovered {
        .home-carousel-item-image {
          transform: scale($home-carousel-transition-scale);
          transition-delay: 0s;
        }
      }

      &.justBeenHovered {
        .home-carousel-item-image {
          transition-delay: 0s;
        }
      }
    }

    &.active {
      &.odd {
        z-index: 6;
      }
    }

    &.previous {
      &.even {
        z-index: 7;
      }
    }
  }

  .home-carousel-item-image {
    width: $home-carousel-width;
    height: $home-carousel-height;

    .videoBackground {
      position: absolute;
    }
  }

  .home-carousel-shuffle {
    top: 50%;
    bottom: auto;
    left: auto;
    right: calc(#{$large-screen-right-indent} + #{$home-carousel-width} + #{$home-carousel-padding} + #{$home-carousel-controls-padding});
    transform: translateY(#{$home-carousel-controls-padding});
  }
}





@media screen and (min-width: $bp-larger) {
  $home-carousel-width: 590px;
  $home-carousel-height: 400px;
  $home-carousel-margin: -70px;
  $home-carousel-controls-padding: 50px;
  $home-carousel-grid: 80px;
  $home-carousel-gutter: 20px;
  $home-carousel-padding: $home-carousel-grid + $home-carousel-gutter;

  .home-carousel-items {
    height: (2 * $home-carousel-height) + $home-carousel-margin;
  }

  .home-carousel-item {

    &.even .home-carousel-item-image:after {
      left: 0;
      right: auto;
    }

    &.odd .home-carousel-item-image:after {
      left: auto;
      right: 0;
    }

    &.even {
      left: 0;
      padding-left: $home-carousel-padding;
      transform: translate(0, -($home-carousel-height + $home-carousel-margin));
    }

    &.odd {
      padding-right: $home-carousel-padding;
      transform: translate(0, $home-carousel-margin);

      .home-carousel-item-text {
        left: $home-carousel-width - $home-carousel-grid;
      }
    }
  }

  .home-carousel-item-image {
    width: $home-carousel-width;
    height: $home-carousel-height;
  }

  .home-carousel-shuffle {
    right: calc(#{$large-screen-right-indent} + #{$home-carousel-width} + #{$home-carousel-padding} + #{$home-carousel-controls-padding});
    transform: translateY(65px);
  }
}
